於是我們繼續導入 github ation
預期的期望是在 PR 時,能夠執行一次並留下紀錄
> [!WARNING]
> Line: 24
這邊我們缺的參數只剩下 commit
, repo
所以我們可以在 action.yml 定義 inputs
並且有些參數可以事先定義預設值(直接從 github action 取得)
可以參考 Context, 如 ${{github.repository}}
最後可以在 runs:
定義 action
name: Leak Detect
description: Detect Potential Leaks.
inputs:
sha:
description: 'The commit you test'
required: true
default: ${{github.event.after}}
repo:
description: 'The repo you test'
required: true
default: ${{github.repository}}
token:
description: 'Github token'
required: true
issue:
description: 'Github issue id'
required: true
default: ${{github.event.number}}
sdk:
description: '[macosx|appletvos|watchsimulator|iphonesimulator|appletvsimulator|iphoneos|watchos]'
required: true
default: ''
module:
description: 'XCode Scheme Name/SPM Target name'
required: true
default: ''
file:
description: 'xxx.xcworkspace/xxx.xcodeproj/xxx.swift'
required: true
default: ''
skip:
description: 'skip list'
required: true
default: '.leakdetect.yml'
runs:
using: 'composite'
steps:
- name: Download LeakDectect
shell: bash
run: |
# TEMP_DIR=$(mktemp -d)
curl -sSL \
"https://github.com/yume190/LeakDetect/releases/download/0.0.8/leakDetect" \
-o leakDetect
chmod +x leakDetect
- name: Detect Single File
if: ${{ inputs.sdk != '' }}
env:
sha: ${{ inputs.sha }}
repository: ${{ inputs.repo }}
auth: ${{ inputs.token }}
issue: ${{ inputs.issue }}
shell: bash
run: |
./leakDetect \
--reporter custom \
--github \
--skip ${{inputs.skip}} \
--sdk ${{inputs.sdk}} \
--file ${{inputs.file}}
- name: Detect Module
if: ${{ inputs.module != '' }}
env:
sha: ${{ inputs.sha }}
repository: ${{ inputs.repo }}
auth: ${{ inputs.token }}
issue: ${{ inputs.issue }}
shell: bash
run: |
./leakDetect \
--reporter custom \
--github \
--skip ${{inputs.skip}} \
--module ${{inputs.module}} \
--file ${{inputs.file}}
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
name: Swift
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: yume190/LeakDetect@0.0.8
with:
module: LeakDetectorDemo
file: LeakDetectorDemo.xcworkspace
token: ${{secrets.GITHUB_TOKEN}}